<?php
if (!defined("LEVEL") || LEVEL < 30 || !defined("OK")) { header('location: ?home'); }
if($url['v'] == 1) {
	//highlight_file(__FILE__);
	//paryskinam koda
	$h = "<table bgcolor=#EEEEEE><tr><td width=30 valign='top'><code>";
	for ($i = 1; $i <= count(file(__FILE__)); $i++) $h .= $i.".<br>";
	$h .= "</code></td><td>";
	$h .= highlight_file(__FILE__, true);
	$h .= "</td></tr></table>";
	hide($_SERVER['PHP_SELF']." - failo turinys",$h);
	unset($h);

}
/*forma=array(
0=>label=Vardas
0=>type=text
0=>value=vardenisPavardenis
1=>label=Šalis
1=>type=select
1=>value=array
1['value'][0]=lietuva
1[value][1]=tadzikija
*/

if (isset($_POST) && !empty($_POST)) { echo "<pre>"; print_r($_POST); echo "<pre>"; }
class test {
    function bandom($bla) { return $bla; }
    function table($pav,$text) {
        return "\n<table width=\"200\" border=\"0\">\n\t<tr>\n\t\t<td><fieldset style=\"border:silver solid 1px\"><legend style=\"color: silver\">$pav</legend>$text</fieldset></td>\n\t</tr>\n</table>\n";
    }
    function trinti($ka,$extra=false) {
        switch ($ka) {
        case "kategorija":
            return $this->table("Trinimas","trinam kategorija");
        case "tema":
            return $this->table("Trinimas","trinam tema");
        case "foruma":
            return $this->table("Trinimas","trinam foruma");
        case "zinute":
            return $this->table("Trinimas","trinam zinute");
        default:
            return $this->table("Klaida","Neteisingai nurodyti parametrai");
        }
    }
    function form($inputs,$pav) {
			if (is_array($inputs)) {
			$return = "\n<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">\n<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"0\">\n\t<tr class=\"title\">\n\t\t<td colspan=\"2\" align=\"left\">".$pav."</td>\n\t</tr>";
			foreach ($inputs as $pav => $type) {
				if (strlen($type) != 0) {
					$return .= "\n\t<tr class=\"sarasas\">\n\t\t<td align=\"right\">".$pav."</td>";
					$return .= "\n\t\t<td><input type=\"".$type."\" name=\"".$pav."\" /></td>\n\t</tr>";
				}
			}
			$return .= "\n\t<tr>\n\t\t<td align=\"right\" class=\"sarasas\"><input type=\"reset\" name=\"Submit2\" value=\"Reset\" /></td>\n\t\t<td class=\"sarasas\"><input type=\"submit\" name=\"Submit\" value=\"Submit\" /></td>\n\t</tr>\n</table>\n</form>\n";
		}
		return $return;
    }
    function input($type,$name,$value,$extra=false) {
		switch ($type) {
			case "select": {
				if (is_array($value)) {
					$return = "<select name=\"select\">\n";
					foreach ($value as $pav => $val) {
						$return .= "\t<option value=\"".$val."\" selected=\"selected\">".$pav."</option>\n";
					}
					$return .= "</select>\n";
				}
			}
			case "text": {
				
			}
		}
    }
}

$bla = new test();
$forma = array(
	"Vardas" => "text",
	"Pavarde" => "text",
	"Emailas" => "text"
	);
echo $bla->form($forma,"Testuojame forma");

echo "<a href=\"".(($url['v']==1)?url('v,0'):url('v,1'))."\">".(($url['v']==1)?"Slėpti kodą":"Žiūrėti kodą")."</a>";
?>
